package com.woniu.day8.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.day8.mapper.HouseMapper;
import com.woniu.day8.pojo.House;
import com.woniu.day8.service.HouseService;
import org.springframework.stereotype.Service;

@Service
public class HouseServiceImpl extends ServiceImpl<HouseMapper, House> implements HouseService {

    @Override
    public Page<House> getHousePage(Page<House> page, House house) {
        QueryWrapper<House> queryWrapper = new QueryWrapper<>();

        // 添加查询条件
        if (house.getId() != null) {
            queryWrapper.eq("id", house.getId());
        }
        if (house.getNumbers() != null) {
            queryWrapper.eq("numbers", house.getNumbers());
        }
        if (house.getStatus() != null) {
            queryWrapper.eq("status", house.getStatus());
        }
        if (house.getBuildingId() != null) {
            queryWrapper.eq("building_id", house.getBuildingId());
        }

        return this.page(page, queryWrapper);
    }
}
